#!/usr/bin/perl
use strict;
my $dir1 = $ARGV[0];
my $currentDir = "$dir1/current";
my $historyDir = "$dir1/history";
if ( "$dir1" eq "" ) {
  print("Usage: tool devconfdir
  This tool will move all history files to subdirs.\n");
} elsif ( ! -d $currentDir ) {
  print("Oops, $currentDir not found.");
} elsif ( ! -d $historyDir ) {
  print("Oops, $historyDir not found.");
} else {
  chdir $currentDir;
  my @list = <*>;
  foreach my $entry (@list) {
    print("Processing $entry\n");
    if ( ! -d "$historyDir/$entry" ) {
      mkdir( "$historyDir/$entry" );
    }
    system(" mv $historyDir/$entry-* $historyDir/$entry ");
  }
}

